import 'package:flutter/material.dart';

class GridViewBuilderCase extends StatelessWidget {
  const GridViewBuilderCase({Key? key}) : super(key: key);
  List<Widget> getChildren() {
    return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((int value) {
      return Container(
          alignment: Alignment.center,
          color: Colors.red,
          child: Text(
            "第$value个",
            style: const TextStyle(color: Colors.white, fontSize: 40),
          ));
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(10),
      child: GridView.builder(
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 4,
              crossAxisSpacing: 10,
              mainAxisSpacing: 10,
              childAspectRatio: 0.5),
          itemBuilder: (BuildContext context, int index) {
            return Container(
              alignment: Alignment.center,
              color: Colors.teal,
              child: Text(
                "第${index + 1}个",
                style: const TextStyle(color: Colors.white, fontSize: 40),
              ),
            );
          },
          itemCount: 50),
    );
  }
}
